package ecustom.common.util;

import org.apache.commons.lang3.StringUtils;

import weaver.file.Prop;

public class PropUtil {
	
	public static Integer getInteger(String name) {
		return getInteger("ecustom", name);
	}
	
	public static Integer getInteger(String propFileName, String name) {
		String str = getString(propFileName, name);
		return CustomUtil.getInteger(str);
	}

	public static String getString(String name) {
		return getString("ecustom", name);
	}

	public static String getString(String propFileName, String propName) {
		return Prop.getPropValue(propFileName, propName);
	}

	public static String getStringCK(String propName) {
		return getStringCK("ecustom", propName);
	}

	public static String getStringCK(String propFileName, String propName) {
		String value = Prop.getPropValue(propFileName, propName);
		if (StringUtils.isBlank(value)) {
			throw new RuntimeException(propFileName + ".properties -> " + propName + " is blank");
		}
		return value;
	}
	
	public static int getIntCK(String propName) {
		return getIntCK("ecustom", propName);
	}
	
	public static int getIntCK(String propFileName, String propName) {
		String value = Prop.getPropValue(propFileName, propName);
		if (StringUtils.isBlank(value)) {
			throw new RuntimeException(propFileName + ".properties -> " + propName + " is blank");
		}
		
		Integer intValue = CustomUtil.getInteger(value);
		if (intValue == null) {
			throw new RuntimeException(propFileName + ".properties -> " + propName + " is not integer");
		}
		return intValue;
	}
}
